import os



def part(name, pos, size, comma=True):
	pos = str(pos)
	size = str(size)
	f.write('\t\t{\n\t\t\t"type": "' + name + '",\n\t\t\t"pos": ' + pos + ',\n\t\t\t"size": ' + size + '\n\t\t}')
	if comma:
		f.write(',')
	f.write('\n')

print "Track generator!\n"
file = raw_input("Filename: ")
name = raw_input("Track name: ")
width = int(raw_input("Width: "))
depth = int(raw_input("Depth: "))
height = int(raw_input("Height: "))
radius = int(raw_input("Block radius: "))

r2 = radius * 2
yzSliceWidth = width - r2
xzSliceHeight = height - r2
xySliceDepth = depth - r2

f = open(os.path.abspath('.') + os.sep + file + ".track", "w")
f.write('{\n\t"name": "' + name + '",\n\t"car": [{\n\t\t"pos": [1.5, 0, 1]\n\t}],\n\t"part": [\n')

part("acblf", [0, 0, 0], [radius, radius, radius])
part("aebf", [radius, 0, 0], [yzSliceWidth, radius, radius])
part("acbrf", [radius + yzSliceWidth, 0, 0], [radius, radius, radius])
part("aebl", [0, 0, radius], [radius, radius, xySliceDepth])
part("asb", [radius, 0, radius], [yzSliceWidth, radius, xySliceDepth])
part("aebr", [radius + yzSliceWidth, 0, radius], [radius, radius, xySliceDepth])
part("acblb", [0, 0, radius + xySliceDepth], [radius, radius, radius])
part("aebb", [radius, 0, radius + xySliceDepth], [yzSliceWidth, radius, radius])
part("acbrb", [radius + yzSliceWidth, 0, radius + xySliceDepth], [radius, radius, radius])
part("aelf", [0, radius, 0], [radius, xzSliceHeight, radius])
part("asf", [radius, radius, 0], [yzSliceWidth, xzSliceHeight, radius])
part("aerf", [radius + yzSliceWidth, radius, 0], [radius, xzSliceHeight, radius])
part("asl", [0, radius, radius], [radius, xzSliceHeight, xySliceDepth])
part("asr", [radius + yzSliceWidth, radius, radius], [radius, xzSliceHeight, xySliceDepth])
part("aelb", [0, radius, radius + xySliceDepth], [radius, xzSliceHeight, radius])
part("asbk", [radius, radius, radius + xySliceDepth], [yzSliceWidth, xzSliceHeight, radius])
part("aerb", [radius + yzSliceWidth, radius, radius + xySliceDepth], [radius, xzSliceHeight, radius])
part("actlf", [0, radius + xzSliceHeight, 0], [radius, radius, radius])
part("aetf", [radius, radius + xzSliceHeight, 0], [yzSliceWidth, radius, radius])
part("actrf", [radius + yzSliceWidth, radius + xzSliceHeight, 0], [radius, radius, radius])
part("aetl", [0, radius + xzSliceHeight, radius], [radius, radius, xySliceDepth])
part("ast", [radius, radius + xzSliceHeight, radius], [yzSliceWidth, radius, xySliceDepth])
part("aetr", [radius + yzSliceWidth, radius + xzSliceHeight, radius], [radius, radius, xySliceDepth])
part("actlb", [0, radius + xzSliceHeight, radius + xySliceDepth], [radius, radius, radius])
part("aetb", [radius, radius + xzSliceHeight, radius + xySliceDepth], [yzSliceWidth, radius, radius])
part("actrb", [radius + yzSliceWidth, radius + xzSliceHeight, radius + xySliceDepth], [radius, radius, radius], False)

f.write('\t]\n}\n')

f.close()
	